From c81fdf2ee6e81080db7d9c367366a00a6a7d77a3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 9 Jul 2017 00:35:05 +0300 Subject: [PATCH] Jettison normalize function and its closures! --- src/cargo/util/toml/targets.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 5cd8ece1a..abf948968 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -55,10 +55,12 @@ pub fn targets(manifest: &TomlManifest, ); // processing the custom build script - let new_build = manifest.maybe_custom_build(custom_build, package_root); + if let Some(custom_build) = manifest.maybe_custom_build(custom_build, package_root) { + let name = format!("build-script-{}", + custom_build.file_stem().and_then(|s| s.to_str()).unwrap_or("")); + targets.push(Target::custom_build_target(&name, package_root.join(custom_build))); + } - // Get targets - targets.extend(normalize(package_root, new_build)); Ok(targets) } @@ -437,26 +439,6 @@ fn configure(toml: &TomlTarget, target: &mut Target) { }); } -fn normalize(package_root: &Path, - custom_build: Option) -> Vec { - let custom_build_target = |dst: &mut Vec, cmd: &Path| { - let name = format!("build-script-{}", - cmd.file_stem().and_then(|s| s.to_str()).unwrap_or("")); - - dst.push(Target::custom_build_target(&name, package_root.join(cmd))); - }; - - - let mut ret = Vec::new(); - - if let Some(custom_build) = custom_build { - custom_build_target(&mut ret, &custom_build); - } - - ret -} - - fn inferred_bin_path(bin: &TomlBinTarget, has_lib: bool, package_root: &Path, -- 2.30.2